package leetcode.all;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Solution187 {
    //暴力遍历所有长为10的子串，n^2
    public List<String> findRepeatedDnaSequences(String s) {
        HashMap<String,Integer> count = new HashMap<>();
        for (int i = 0; i <= s.length() - 10; i++) {
            String subString = s.substring(i, i + 10);
            count.put(subString,count.getOrDefault(subString,0)+1);
        }
        ArrayList<String> res = new ArrayList<>();
        for (String s1 : count.keySet()) {
            if(count.get(s1)>1) res.add(s1);
        }
        return res;
    }
}
